<?php

namespace Kateba\SiteBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Service
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Kateba\SiteBundle\Entity\ServiceRepository")
 */
class Service {

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var \Kateba\SiteBundle\Entity\Category
     *
     * @ORM\ManyToOne(targetEntity="\Kateba\SiteBundle\Entity\Category", inversedBy="services")
     * @ORM\JoinColumn(name="category_id", referencedColumnName="id", onDelete="CASCADE", nullable=false)
     */
    private $category;
    
    /**
     * @var \Kateba\SiteBundle\Entity\UserService[]
     *
     * @ORM\OneToMany(targetEntity="\Kateba\SiteBundle\Entity\UserService", mappedBy="service", cascade={"remove"}, orphanRemoval=true)
     */
    private $userServices;

    /**
     * @var string
     * @Assert\NotBlank
     * @ORM\Column(name="nameEn", type="string", length=255)
     */
    private $nameEn;

    /**
     * @var string
     * @ORM\Column(name="nameAr", type="string", length=255, nullable=true)
     */
    private $nameAr;

    /**
     * @var string
     * @Assert\NotBlank
     * @ORM\Column(name="descriptionEn", type="text")
     */
    private $descriptionEn;

    /**
     * @var string
     * @ORM\Column(name="descriptionAr", type="text", nullable=true)
     */
    private $descriptionAr;

    /**
     * @var float
     * @Assert\NotBlank
     * @ORM\Column(name="price", type="float")
     */
    private $price;
    
    /**
     * @var float
     * @Assert\NotBlank
     * @ORM\Column(name="rushPrice", type="float")
     */
    private $rushPrice;

    public function __toString() {
        return (string) $this->nameEn;
    }

    /**
     * Get id
     *
     * @return integer
     */
    public function getId() {
        return $this->id;
    }

    /**
     * Constructor
     */
    public function __construct() {
        $this->userServices = new ArrayCollection();
    }

    /**
     * Set nameEn
     *
     * @param string $nameEn
     * @return Service
     */
    public function setNameEn($nameEn) {
        $this->nameEn = $nameEn;

        return $this;
    }

    /**
     * Get nameEn
     *
     * @return string
     */
    public function getNameEn() {
        return $this->nameEn;
    }

    /**
     * Set nameAr
     *
     * @param string $nameAr
     * @return Service
     */
    public function setNameAr($nameAr) {
        $this->nameAr = $nameAr;

        return $this;
    }

    /**
     * Get nameAr
     *
     * @return string
     */
    public function getNameAr() {
        return $this->nameAr;
    }

    /**
     * Set descriptionEn
     *
     * @param string $descriptionEn
     * @return Service
     */
    public function setDescriptionEn($descriptionEn) {
        $this->descriptionEn = $descriptionEn;

        return $this;
    }

    /**
     * Get descriptionEn
     *
     * @return string
     */
    public function getDescriptionEn() {
        return $this->descriptionEn;
    }

    /**
     * Set descriptionAr
     *
     * @param string $descriptionAr
     * @return Service
     */
    public function setDescriptionAr($descriptionAr) {
        $this->descriptionAr = $descriptionAr;

        return $this;
    }

    /**
     * Get descriptionAr
     *
     * @return string
     */
    public function getDescriptionAr() {
        return $this->descriptionAr;
    }

    /**
     * Set price
     *
     * @param float $price
     * @return Service
     */
    public function setPrice($price) {
        $this->price = $price;

        return $this;
    }

    /**
     * Get price
     *
     * @return float
     */
    public function getPrice() {
        return $this->price;
    }

    /**
     * Add userServices
     *
     * @param \Kateba\SiteBundle\Entity\UserService $userServices
     * @return Service
     */
    public function addUserService(\Kateba\SiteBundle\Entity\UserService $userServices) {
        $this->userServices[] = $userServices;

        return $this;
    }

    /**
     * Remove userServices
     *
     * @param \Kateba\SiteBundle\Entity\UserService $userServices
     */
    public function removeUserService(\Kateba\SiteBundle\Entity\UserService $userServices) {
        $this->userServices->removeElement($userServices);
    }

    /**
     * Get userServices
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getUserServices() {
        return $this->userServices;
    }

    /**
     * this function used to get service name for locale
     * @author ahmed
     * @param string $locale
     */
    public function getName($locale = 'en') {
        if ($locale == 'en') {
            return $this->nameEn;
        } else {
            if ($this->nameAr)
                return $this->nameAr;
            else
                return $this->nameEn;
        }
    }

    public function getDescription($locale = 'en') {
        if ($locale == 'en') {
            return $this->descriptionEn;
        } else {
            if ($this->descriptionAr)
                return $this->descriptionAr;
            else
                return $this->descriptionEn;
        }
    }


    /**
     * Set category
     *
     * @param \Kateba\SiteBundle\Entity\Category $category
     * @return Service
     */
    public function setCategory(\Kateba\SiteBundle\Entity\Category $category)
    {
        $this->category = $category;
    
        return $this;
    }

    /**
     * Get category
     *
     * @return \Kateba\SiteBundle\Entity\Category 
     */
    public function getCategory()
    {
        return $this->category;
    }

    /**
     * Set rushPrice
     *
     * @param float $rushPrice
     * @return Service
     */
    public function setRushPrice($rushPrice)
    {
        $this->rushPrice = $rushPrice;
    
        return $this;
    }

    /**
     * Get rushPrice
     *
     * @return float 
     */
    public function getRushPrice()
    {
        return $this->rushPrice;
    }
}